package com.example.demo;

import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONArray;
import com.clearofchina.core.util.StringUtil;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @author gxing
 * @desc TODO
 * @date 2023/8/1
 */
public class MainTest3 {

    public static String accessDomain = "http://www.baidu.com";

    public static void main(String[] args) {
        String url = "/img/1111.jpg";
        System.out.println(getAbsoluteUrl(url));

    }

    /**
     * 传入相对路径,返回绝对路径
     * @param url 路径
     * @return 绝对路径
     */
    public static String getAbsoluteUrl(String url) {
        return StringUtil.isNotBlank(url) && !url.startsWith("http") ? accessDomain + url : url;
    }

}
